package com.efast.cafe.portal.service.doc.impl;

import java.util.Date;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.efast.cafe.framework.util.SpringWebUtils;
import com.efast.cafe.portal.bean.doc.DocAttrsQueryBean;
import com.efast.cafe.portal.dao.doc.DocAttrsDao;
import com.efast.cafe.portal.entity.doc.DocAttrs;
import com.efast.cafe.portal.service.doc.IDocAttrsService;
import com.github.pagehelper.PageHelper;
@Service
@Transactional
public class DocAttrsServiceImpl implements IDocAttrsService{
	
	@Autowired
	private DocAttrsDao docAttrsDao;

	@Override
	public DocAttrsQueryBean queryDocAttrs(DocAttrsQueryBean docAttrsQueryBean) {
		/*if(StringUtil.isNullOrBlank(docAttrsQueryBean.getCompanyCode())){
			docAttrsQueryBean.setCompanyCode(SpringWebUtils.getRequestCompany());
		}*/
		PageHelper.startPage(docAttrsQueryBean.getStart(),docAttrsQueryBean.getLength());
		docAttrsQueryBean.setResultList(docAttrsDao.queryAttrsList(docAttrsQueryBean));
		docAttrsQueryBean.setTotalRows(docAttrsDao.queryAttrsCount(docAttrsQueryBean));
		return docAttrsQueryBean;
	}

	@Override
	public void addDocAttrs(DocAttrs docAttrs) {
		docAttrs.setCompanyCode(SpringWebUtils.getRequestCompany());
		docAttrs.setCreateUser(SpringWebUtils.getRequestUser());
		docAttrs.setCreateTime(new Date());
		docAttrsDao.addDocAttrs(docAttrs);
	}

	@Override
	public void updateDocAttrs(DocAttrs docAttrs) {
		docAttrsDao.updateDocAttrs(docAttrs);
		
	}

	@Override
	public void deleteDocAttrs(Integer id) {
		docAttrsDao.deleteDocAttrs(id);
		
	}

}
